import { createPortal } from "react-dom";
import React, { Component } from "react";

// 写一个将组件统一放在body里的高阶组件
// 高阶组件最好约定成with开头
const withPortal = (Comp) => {
  return class extends Component {
    render() {
      return createPortal(
        <Comp {...this.props}></Comp>,
        document.querySelector("body")
      );
    }
  };
};

export default withPortal;
